26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
50 #pragma package(smart_init)
63 Graphics::TBitmap* SmallGraphicPtrVal) : SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
65 for(
int x = 0; x < 4; x++)
76 else if(SpeedTagVal == 77)
80 else if(SpeedTagVal == 78)
84 else if(SpeedTagVal == 79)
88 else if(SpeedTagVal == 96)
92 else if(SpeedTagVal == 129)
96 else if(SpeedTagVal == 130)
100 else if(SpeedTagVal == 131)
104 else if(SpeedTagVal == 145)
108 else if(SpeedTagVal == 146)
117 FixedNamedLocationElement(false)
119 for(
int x = 0; x < 4; x++)
130 AnsiString(VLocInput));
143 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
157 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
173 Graphics::TBitmap *GraphicOutput = GraphicPtr;
175 if(LocationName ==
"")
220 GraphicOutput = GraphicPtr;
224 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
233 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
234 AnsiString(TrainIDOnBridgeTrackPos01) +
"," + AnsiString(TrainIDOnBridgeTrackPos23) +
",EndTrkEl,";
243 if(lower.second < higher.second)
247 else if(lower.second > higher.second)
251 else if(lower.second == higher.second)
253 if(lower.first < higher.first)
266 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
267 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
271 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
282 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
310 {2, 4}, {6, 2}, {8, 6}, {4, 8},
311 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
321 else if(
Link[2] == -1)
334 else if(
Link[2] == -1)
343 for(
int x = 0; x < 16; x++)
345 if(((Entry == EXArray[x][0]) && (Exit == EXArray[x][1])) || ((Entry == EXArray[x][1]) && (Exit == EXArray[x][0])))
521 throw Exception(
"Error in EntryExitNumber 4");
616 throw Exception(
"Error in EntryExitNumber 5");
713 throw Exception(
"Error in EntryExitNumber 6");
803 throw Exception(
"Error in EntryExitNumber 10");
893 throw Exception(
"Error in EntryExitNumber 11");
989 throw Exception(
"Error in EntryExitNumber 7");
1020 throw Exception(
"Error in EntryExitNumber 8");
1031 if((ELink > 0) && (ELink < 10) && (ELink != 5))
1033 if(!AutoSigsFlag && !PrefDirRoute)
1037 else if(!AutoSigsFlag && PrefDirRoute)
1048 throw Exception(
"Error in EntryExitNumber 9");
1092 TTrack::TActiveLevelCrossing::TActiveLevelCrossing()
1117 AnsiString NL =
'\n';
1119 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable; " + NL + NL +
1120 "reachable but with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
1121 "blocked by a train, another route or a changing level crossing; " + NL + NL +
1122 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
1129 int InternalLinkCheckArray[9][2] =
1130 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
1135 for(
int x = 0; x < 9; x++)
1137 for(
int y = 0; y < 2; y++)
1144 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
1146 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
1147 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
1148 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
1149 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27
1150 << 60 << 61 << 62 << 63 << 68 << 69 << 70 << 71 << 80 << 81 << 82 << 83 << 125 << 126 << 127 << 128;
1156 int HVArray[10][2] =
1157 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
1159 for(
int x = 0; x < 10; x++)
1161 for(
int y = 0; y < 2; y++)
1170 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1173 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1174 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1176 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
1177 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
1179 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1180 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1183 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1186 for(
int x = 0; x < 40; x++)
1192 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1195 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1196 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1198 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1199 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1201 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1202 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1205 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1208 for(
int x = 0; x < 40; x++)
1214 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1217 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
1218 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1220 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1221 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1223 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1224 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1227 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1230 for(
int x = 0; x < 40; x++)
1256 for(
int x = 0; x < 40; x++)
1283 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1284 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1285 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1286 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1287 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1288 {0, 0, 129}, {0, -1, 145},
1291 for(
int x = 0; x < 25; x++)
1293 for(
int y = 0; y < 3; y++)
1301 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1302 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1303 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1304 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1305 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1306 {0, 0, 129}, {0, 1, 145},
1309 for(
int x = 0; x < 25; x++)
1311 for(
int y = 0; y < 3; y++)
1319 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1320 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1321 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1322 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1323 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1324 {0, 0, 130}, {-1, 0, 146},
1327 for(
int x = 0; x < 25; x++)
1329 for(
int y = 0; y < 3; y++)
1337 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1338 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1339 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1340 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1341 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1342 {0, 0, 130}, {1, 0, 146},
1345 for(
int x = 0; x < 25; x++)
1347 for(
int y = 0; y < 3; y++)
1355 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1356 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1357 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1358 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1359 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1360 {0, -1, 129}, {1, 0, 130},
1361 {-1, 0, 130}, {0, 1, 145},
1362 {0, -1, 145}, {1, 0, 146},
1365 for(
int x = 0; x < 28; x++)
1367 for(
int y = 0; y < 3; y++)
1385 for(
int x = 0; x < 8; x++)
1387 for(
int y = 0; y < 3; y++)
1405 for(
int x = 0; x < 8; x++)
1407 for(
int y = 0; y < 3; y++)
1425 for(
int x = 0; x < 8; x++)
1427 for(
int y = 0; y < 3; y++)
1445 for(
int x = 0; x < 8; x++)
1447 for(
int y = 0; y < 3; y++)
1455 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1457 for(
int x = 0; x < 4; x++)
1459 for(
int y = 0; y < 3; y++)
1467 0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1468 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1469 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1470 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1476 0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1477 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1478 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1479 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1485 0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1486 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1487 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1488 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1494 0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1495 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1496 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1497 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1519 delete UGMIt->second;
1595 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1596 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1598 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1605 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1606 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1619 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1620 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1622 {4, 6, 2, 8}, {1, 9, 3, 7},
1624 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1626 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8}, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1629 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1630 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6}, {3, 7, 4, 6},
1631 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1632 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1},
1633 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1634 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1635 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1637 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1638 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1639 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1640 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1641 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1642 {4, 6, -1, -1}, {2, 8, -1, -1},
1644 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1646 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1648 {4, 6, -1, -1}, {2, 8, -1, -1},
1653 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1654 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1655 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1656 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1659 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1660 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1661 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1663 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1664 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1665 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1667 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1669 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1670 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1671 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1672 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1673 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1674 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1675 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1676 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1677 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1678 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1679 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1680 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1681 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1683 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1684 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1685 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1686 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1687 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1688 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1689 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1690 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1694 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1695 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1696 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1702 for(
int x = 0; x < 17; x++)
1704 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1706 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1710 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1716 ExistingGraphicLoaded(false), Width(16), Height(16)
1728 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1766 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1770 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1774 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1778 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1801 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1804 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1808 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1812 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1846 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1867 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1881 bool TrackPresent =
false;
1895 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1899 TrackPresent =
true;
1904 return(!TrackPresent);
1912 bool TrackPresent =
false;
1921 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1925 TrackPresent =
true;
1931 return(!TrackPresent);
1936 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
1939 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
1940 TrackEraseSuccessfulFlag =
false;
1945 ErasedTrackVectorPosition = -1;
1946 AnsiString SName =
"", ErrorString;
1948 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
1954 TrackMapKeyPair.first = HLocInput;
1955 TrackMapKeyPair.second = VLocInput;
1956 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
1967 if(ErrorString !=
"")
1969 throw Exception(ErrorString +
" for EraseTrackElement 1");
1993 ErasedTrackVectorPosition = VecPos;
1994 TrackEraseSuccessfulFlag =
true;
2000 unsigned int VecPos;
2001 InactiveTrackMapKeyPair.first = HLocInput;
2002 InactiveTrackMapKeyPair.second = VLocInput;
2007 VecPos = InactiveTrack2MultiMapIterator->second;
2012 if(ErrorString !=
"")
2014 throw Exception(ErrorString +
" for EraseTrackElement 2A");
2024 TrackEraseSuccessfulFlag =
true;
2045 VecPos = InactiveTrack2MultiMapIterator->second;
2050 if(ErrorString !=
"")
2052 throw Exception(ErrorString +
" for EraseTrackElement 2B");
2076 if(TrackEraseSuccessfulFlag)
2098 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2099 bool PlatAllowedFlag =
false;
2101 TrackLinkingRequiredFlag =
false;
2113 LocationNameEntry.first =
"";
2121 TempTrackElement.
HLoc = HLocInput;
2122 TempTrackElement.
VLoc = VLocInput;
2148 else if(Aspect == 1)
2152 else if(Aspect == 2)
2156 else if(Aspect == 3)
2165 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2168 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2170 if(InactiveFoundFlag)
2174 NonStationOrLevelCrossingPresent =
true;
2178 NonStationOrLevelCrossingPresent =
true;
2182 PlatformPresent =
true;
2193 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2201 PlatAllowedFlag =
true;
2205 PlatAllowedFlag =
true;
2209 PlatAllowedFlag =
true;
2213 PlatAllowedFlag =
true;
2217 TrackLinkingRequiredFlag =
true;
2245 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1048, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2246 (!FoundFlag && !InactiveFoundFlag))
2249 TrackLinkingRequiredFlag =
true;
2281 TrackLinkingRequiredFlag =
true;
2293 else if(FoundFlag || InactiveFoundFlag)
2312 bool BothPointFillets =
true;
2327 TrackLinkingRequiredFlag =
true;
2341 bool InternalChecks)
2345 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2346 bool PlatAllowedFlag =
false;
2348 TrackLinkingRequiredFlag =
false;
2351 LocationNameEntry.first =
"";
2357 TempTrackElement.
HLoc = HLocInput;
2358 TempTrackElement.
VLoc = VLocInput;
2359 for(
int x = 0; x < 4; x++)
2365 TempTrackElement.
Conn[x] = -1;
2369 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2380 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2382 if(InactiveFoundFlag)
2386 NonStationOrLevelCrossingPresent =
true;
2390 NonStationOrLevelCrossingPresent =
true;
2394 PlatformPresent =
true;
2405 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2413 PlatAllowedFlag =
true;
2417 PlatAllowedFlag =
true;
2421 PlatAllowedFlag =
true;
2425 PlatAllowedFlag =
true;
2429 TrackLinkingRequiredFlag =
true;
2460 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1055, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2461 (!FoundFlag && !InactiveFoundFlag))
2464 TrackLinkingRequiredFlag =
true;
2499 TrackLinkingRequiredFlag =
true;
2511 else if(FoundFlag || InactiveFoundFlag)
2530 bool BothPointFillets =
true;
2545 TrackLinkingRequiredFlag =
true;
2575 ShowMessage(
"Gaps must be set before track can be validated");
2585 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2596 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2613 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2620 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2644 std::pair<AnsiString, char>TempMapPair;
2652 TempMapPair.second =
'x';
2665 int NewHLoc, NewVLoc;
2666 bool ConnectionFoundFlag, LinkFoundFlag;
2668 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2670 for(
unsigned int y = 0; y < 4; y++)
2688 ConnectionFoundFlag =
false;
2689 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2695 ConnectionFoundFlag =
true;
2697 LinkFoundFlag =
false;
2698 for(
unsigned int a = 0; a < 4; a++)
2702 LinkFoundFlag =
true;
2718 if(!ConnectionFoundFlag)
2793 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2810 bool UnsetGaps =
false;
2817 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2821 for(
unsigned int y = 0; y < 4; y++)
2833 for(
unsigned int y = 0; y < 4; y++)
2843 for(
unsigned int y = 1; y < 4; y++)
2852 for(
unsigned int y = 0; y < 4; y++)
2865 for(
unsigned int y = 0; y < 4; y++)
2893 int NumberOfActiveElements = 0;
2895 GraphicsFollow =
false;
2899 if(MarkerString[MarkerString.Length()] ==
'1')
2901 GraphicsFollow =
true;
2903 for(
int x = 0; x < NumberOfActiveElements; x++)
2909 TrackElement.
HLoc = TempInt;
2911 TrackElement.
VLoc = TempInt;
2917 TrackElement.
Conn[0] = TempInt;
2941 if((TempInt != -1) && (TempInt < 10))
2951 if((TempInt != -1) && (TempInt < 10))
2968 if(Marker[1] ==
'3')
2972 else if(Marker[1] ==
'2')
2976 else if(Marker[1] ==
'G')
2990 int NumberOfInactiveElements = 0;
2994 for(
int x = 0; x < NumberOfInactiveElements; x++)
3000 TrackElement.
HLoc = TempInt;
3002 TrackElement.
VLoc = TempInt;
3008 bool LocError =
false;
3037 for(
int x = 0; x < NumberOfGraphics; x++)
3048 bool FileError =
false;
3050 for(
int x = 0; x < NumberOfGraphics; x++)
3063 UGME.second =
new TPicture;
3064 UGME.second->LoadFromFile(
UGME.first);
3067 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
3074 catch(
const EInvalidGraphic &e)
3083 delete UGMIt->second;
3088 catch(
const Exception &e)
3097 delete UGMIt->second;
3105 bool FoundInMap =
false;
3124 UGME.second =
new TPicture;
3125 UGME.second->LoadFromFile(
UGME.first);
3128 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
3135 catch(
const EInvalidGraphic &e)
3144 delete UGMIt->second;
3149 catch(
const Exception &e)
3158 delete UGMIt->second;
3183 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
3187 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
3189 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
3192 VecFile << x <<
'\n';
3193 VecFile << TrackElement.
SpeedTag <<
'\n';
3194 VecFile << TrackElement.
HLoc <<
'\n';
3195 VecFile << TrackElement.
VLoc <<
'\n';
3199 VecFile << TrackElement.
Conn[0] <<
'\n';
3203 VecFile << TrackElement.
Attribute <<
'\n';
3209 VecFile << int(1) <<
'\n';
3213 VecFile << int(0) <<
'\n';
3216 VecFile << TrackElement.
Length01 <<
'\n';
3217 VecFile << TrackElement.
Length23 <<
'\n';
3220 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3227 VecFile <<
"3*****" <<
'\0' <<
'\n';
3231 VecFile <<
"2*****" <<
'\0' <<
'\n';
3235 VecFile <<
"G*****" <<
'\0' <<
'\n';
3239 VecFile <<
"4*****" <<
'\0' <<
'\n';
3244 VecFile <<
"******" <<
'\0' <<
'\n';
3249 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
3253 VecFile << x <<
'\n';
3254 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
3255 VecFile << InactiveTrackElement.
HLoc <<
'\n';
3256 VecFile << InactiveTrackElement.
VLoc <<
'\n';
3257 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3258 VecFile <<
"******" <<
'\0' <<
'\n';
3273 GraphicsFollow =
false;
3275 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
3281 AnsiString MarkerString;
3288 if(MarkerString[MarkerString.Length()] ==
'1')
3290 GraphicsFollow =
true;
3292 for(
int x = 0; x < NumberOfActiveElements; x++)
3300 int SpeedTag = TempInt;
3307 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3313 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3318 if((SpeedTag > 87) && (SpeedTag < 96))
3321 if((TempInt < -1) || (TempInt > 3))
3327 if((TempInt < -1) || (TempInt > 999999))
3333 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3334 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3337 if((TempInt < -1) || (TempInt > 5))
3343 if((SpeedTag >= 68) && (SpeedTag <= 75))
3346 if((TempInt != 0) && (TempInt != 1))
3353 if((TempInt < -1) || (TempInt > 999999))
3359 if((TempInt < -1) || (TempInt > 999999))
3365 if((TempInt < -1) || (TempInt > 999999))
3371 if((TempInt < -1) || (TempInt > 999999))
3392 int NumberOfInactiveElements = 0;
3395 if(NumberOfInactiveElements < 0)
3405 for(
int x = 0; x < NumberOfInactiveElements; x++)
3419 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3425 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3452 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3458 AnsiString FileName =
"", TempStr =
"";
3460 for(
int x = 0; x < NumberOfGraphics; x++)
3462 TPicture *TempPicture =
new TPicture;
3471 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3484 catch(
const EInvalidGraphic &e)
3489 for(
int y = x + 1; y < NumberOfGraphics; y++)
3495 ShowMessage(FileName +
3496 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3501 catch(
const Exception &e)
3506 for(
int y = x + 1; y < NumberOfGraphics; y++)
3512 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3513 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3531 for(
int x = 0; x < VecSize; x++)
3554 for(
int x = 0; x < VecSize; x++)
3576 for(
int x = 0; x < VecSize; x++)
3630 for(
int x = 0; x < VecSize; x++)
3688 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3706 if(BothPointFilletsAndBasicLCs)
3781 Bitmap->Canvas->CopyMode = cmSrcCopy;
3783 Graphics::TBitmap *GraphicOutput;
3955 for(
int x = 0; x < 40; x++)
3984 Graphics::TBitmap *GraphicPtr;
3999 Graphics::TBitmap* SignalPlatformGraphic;
4032 if(OldTransparentColour !=
clB5G5R5)
4055 Bitmap->Canvas->CopyMode = cmSrcCopy;
4083 Bitmap->Canvas->CopyMode = cmSrcCopy;
4085 Graphics::TBitmap *GraphicOutput;
4095 if(BaseElement == 1)
4183 for(
int x = 0; x < 40; x++)
4212 Graphics::TBitmap *GraphicPtr;
4227 Graphics::TBitmap* SignalPlatformGraphic;
4288 for(
int x = 0; x < 40; x++)
4296 Graphics::TBitmap* SignalPlatformGraphic;
4317 if(OldTransparentColour !=
clB5G5R5)
4331 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4403 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4417 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4443 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4468 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4498 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4532 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4569 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4584 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4613 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4620 throw Exception(
"Error - Map & Vector different sizes");
4622 unsigned int NonZeroCount = 0;
4624 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4633 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4639 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4643 TrackMapEntry.first = TrackMapKeyPair;
4644 TrackMapEntry.second = x;
4645 if(!(
TrackMap.insert(TrackMapEntry).second))
4647 throw Exception(
"Error - map insertion failure, TrackVector in error");
4651 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4653 for(
unsigned int y = 0; y < 4; y++)
4678 THVPair GapMapKeyPair, GapMapValuePair;
4681 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4687 GapMapEntry.first = GapMapKeyPair;
4690 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4694 GapMapEntry.second = GapMapValuePair;
4697 GapMap.insert(GapMapEntry);
4710 bool CheckForLinks =
false;
4712 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4724 "Footbridge or underpass connection error. Each end must connect to a platform, concourse "
4725 "or other footbridge or underpass, and they can't connect to each other (i.e. a footbridge "
4726 "can't connect to an underpass or vice versa)");
4734 for(
unsigned int y = 0; y < 4; y++)
4736 CheckForLinks =
false;
4754 bool ConnectionFoundFlag;
4758 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4764 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4773 if(ConnectionFoundFlag)
4777 bool LinkFoundFlag =
false;
4781 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
4787 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
4793 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
4801 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
4807 ShowMessage(
"Signal facing a bridge - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
4814 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
4818 CheckForLinks =
true;
4822 for(
unsigned int a = 0; a < 4; a++)
4831 LinkFoundFlag =
true;
4844 throw Exception(
"Error in final track linkage - invalid link");
4858 throw Exception(
"Error in final track linkage - connection not found");
4871 bool ConnErrorFlag =
false;
4873 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4877 ConnErrorFlag =
true;
4881 ConnErrorFlag =
true;
4885 ConnErrorFlag =
true;
4889 ConnErrorFlag =
true;
4897 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
4906 throw Exception(
"ConnError in LinkTrack - Final");
4910 throw Exception(
"ConnError in LinkTrack - Precheck");
4913 bool CLkErrorFlag =
false;
4915 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4919 CLkErrorFlag =
true;
4923 CLkErrorFlag =
true;
4927 CLkErrorFlag =
true;
4931 CLkErrorFlag =
true;
4939 throw Exception(
"CLkError in LinkTrack - Final");
4943 throw Exception(
"CLkError in LinkTrack - Precheck");
4947 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4977 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4993 for(
unsigned int y = 0; y < 4; y++)
5012 bool ConnectionFoundFlag;
5018 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5027 if(ConnectionFoundFlag)
5030 bool LinkFoundFlag =
false;
5087 for(
unsigned int a = 0; a < 4; a++)
5096 LinkFoundFlag =
true;
5104 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
5114 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
5127 bool ConnErrorFlag =
false;
5129 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5133 ConnErrorFlag =
true;
5137 ConnErrorFlag =
true;
5141 ConnErrorFlag =
true;
5145 ConnErrorFlag =
true;
5153 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5162 throw Exception(
"ConnError in LinkTrack - Final");
5166 throw Exception(
"ConnError in LinkTrack - Precheck");
5169 bool CLkErrorFlag =
false;
5171 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5175 CLkErrorFlag =
true;
5179 CLkErrorFlag =
true;
5183 CLkErrorFlag =
true;
5187 CLkErrorFlag =
true;
5195 throw Exception(
"CLkError in LinkTrack - Final");
5199 throw Exception(
"CLkError in LinkTrack - Precheck");
5203 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5232 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5248 for(
unsigned int y = 0; y < 4; y++)
5267 bool ConnectionFoundFlag =
false;
5269 if(ConnectionFoundFlag)
5273 bool LinkFoundFlag =
false;
5293 for(
unsigned int a = 0; a < 4; a++)
5302 LinkFoundFlag =
true;
5322 bool ConnErrorFlag =
false;
5324 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5328 ConnErrorFlag =
true;
5332 ConnErrorFlag =
true;
5336 ConnErrorFlag =
true;
5340 ConnErrorFlag =
true;
5348 bool CLkErrorFlag =
false;
5350 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5354 CLkErrorFlag =
true;
5358 CLkErrorFlag =
true;
5362 CLkErrorFlag =
true;
5366 CLkErrorFlag =
true;
5384 int Position1, Position2;
5390 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
5392 int HLoc1 = GapMapPtr->first.first;
5393 int VLoc1 = GapMapPtr->first.second;
5394 int HLoc2 = GapMapPtr->second.first;
5395 int VLoc2 = GapMapPtr->second.second;
5398 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
5402 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
5406 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
5410 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
5428 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
5429 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5439 bool FoundFlag =
false;
5451 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5452 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5453 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5482 bool FoundFlag =
false;
5495 TrackMapKeyPair.first = TrackElement.
HLoc;
5496 TrackMapKeyPair.second = TrackElement.
VLoc;
5497 TrackMapEntry.first = TrackMapKeyPair;
5502 LocationNameEntry.second = -(int)(
TrackVector.size());
5542 TrackMapKeyPair.first = HLoc;
5543 TrackMapKeyPair.second = VLoc;
5544 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5554 return(TrackMapPtr->second);
5567 TrackMapKeyPair.first = HLoc;
5568 TrackMapKeyPair.second = VLoc;
5569 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5572 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5573 throw Exception(Message);
5591 MapKeyPair.first = HLoc;
5592 MapKeyPair.second = VLoc;
5593 MapPtr = Map.find(MapKeyPair);
5594 if(MapPtr == Map.end())
5596 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc) +
" in GetTrackElementFromAnyTrackMap";
5597 throw Exception(Message);
5602 return(Vector.at(MapPtr->second));
5612 THVPair InactiveTrackMapKeyPair;
5615 InactiveTrackMapKeyPair.first = HLoc;
5616 InactiveTrackMapKeyPair.second = VLoc;
5620 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5621 throw Exception(Message);
5635 bool Present =
true;
5639 TrackMapKeyPair.first = HLoc;
5640 TrackMapKeyPair.second = VLoc;
5641 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5656 bool Present =
true;
5657 THVPair InactiveTrackMapKeyPair;
5660 InactiveTrackMapKeyPair.first = HLoc;
5661 InactiveTrackMapKeyPair.second = VLoc;
5679 THVPair InactiveTrackMapKeyPair;
5684 InactiveTrackMapKeyPair.first = HLoc;
5685 InactiveTrackMapKeyPair.second = VLoc;
5694 if(InactiveTrackRange.first == InactiveTrackRange.second)
5703 RetPair.first = InactiveTrackRange.first->second;
5704 RetPair.second = (--InactiveTrackRange.second)->second;
5717 AnsiString(DivergingPosition));
5728 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
5729 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
5730 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
5731 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
5732 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
5733 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
5734 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
5735 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
5736 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
5737 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
5738 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
5739 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
5773 throw Exception(
"Error, Wrong track type in PlotGap");
5775 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
5779 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
5783 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
5787 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
5791 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
5795 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
5799 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
5803 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
5807 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
5811 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
5815 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
5819 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
5823 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
5827 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
5831 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
5835 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
5849 throw Exception(
"Error, Wrong track type in PlotPoints");
5860 else if(TrackElement.
SpeedTag < 132)
5878 else if(TrackElement.
SpeedTag < 132)
5911 throw Exception(
"Error, Wrong track type in PlotSignal");
5913 for(
int x = 0; x < 40; x++)
5984 for(
int x = 0; x < 40; x++)
5991 Graphics::TBitmap* SignalPlatformGraphic;
6078 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
6086 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
6094 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
6102 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
6118 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
6126 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
6134 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
6142 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
6175 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
6187 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
6199 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
6211 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
6253 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
6255 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6257 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
6260 if(BaseElementSpeedTag == 1)
6264 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
6271 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
6279 Graphics::TBitmap *RouteGraphic;
6281 if(TypeOfRoute == 1)
6285 else if(TypeOfRoute == 0)
6291 RouteGraphic = BaseGraphic;
6298 if(UpStep == DownStep)
6301 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
6311 else if((DownStep - UpStep) == 1)
6316 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6326 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6339 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6349 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6365 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6375 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6385 else if(DownStep == 0)
6388 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6398 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6411 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6421 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6431 for(
int x = (UpStep + 1); x < DownStep; x++)
6436 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
6440 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
6461 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
6468 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
6474 Graphics::TBitmap *RouteGraphic;
6476 if(TypeOfRoute == 1)
6480 else if(TypeOfRoute == 0)
6486 RouteGraphic = BaseGraphic;
6495 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6505 else if((RStep - LStep) == 1)
6510 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6520 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6533 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6543 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6559 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6569 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6582 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6592 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6605 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6615 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6625 for(
int x = (LStep + 1); x < RStep; x++)
6630 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
6634 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
6658 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6661 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6663 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6665 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6668 if(BaseElementSpeedTag == 1)
6672 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
6679 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
6685 if(UpStep == DownStep)
6696 else if((DownStep - UpStep) == 1)
6715 for(
int x = (UpStep + 1); x < DownStep; x++)
6724 for(
int x = (UpStep + 1); x < DownStep; x++)
6731 for(
int x = UpStep; x <= DownStep; x++)
6744 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
6751 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
6768 else if((RStep - LStep) == 1)
6787 for(
int x = (LStep + 1); x < RStep; x++)
6796 for(
int x = (LStep + 1); x < RStep; x++)
6803 for(
int x = LStep; x <= RStep; x++)
6822 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
6824 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6826 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
6829 if(BaseElementSpeedTag == 1)
6833 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
6840 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
6846 for(
int x = UpStep; x < (DownStep + 1); x++)
6861 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
6868 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
6874 for(
int x = LStep; x < (RStep + 1); x++)
6893 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6896 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6898 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6900 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6905 if(BaseElementSpeedTag == 1)
6909 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
6916 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
6922 for(
int x = UpStep; x <= DownStep; x++)
6936 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
6943 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
6949 for(
int x = LStep; x <= RStep; x++)
6965 Graphics::TBitmap *RouteGraphic;
6968 if(BaseElementSpeedTag == 1)
6970 if(TypeOfRoute == 1)
6974 else if(TypeOfRoute == 0)
6980 RouteGraphic = BaseGraphic;
6984 RouteGraphic = BaseGraphic;
6990 if(TypeOfRoute == 1)
6994 else if(TypeOfRoute == 0)
7000 RouteGraphic = BaseGraphic;
7004 RouteGraphic = BaseGraphic;
7009 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
7014 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
7018 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
7025 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
7028 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
7033 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
7038 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
7042 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
7049 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
7052 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
7177 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7181 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7212 "," + AnsiString(VLoc));
7216 int DummyRouteNumber;
7218 TrainPresent =
false;
7222 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
7224 TrackMapKeyPair.first = HLoc;
7225 TrackMapKeyPair.second = VLoc + UpStep;
7226 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7235 TrainPresent =
true;
7249 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
7251 TrackMapKeyPair.first = HLoc;
7252 TrackMapKeyPair.second = VLoc + DownStep;
7253 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7262 TrainPresent =
true;
7276 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
7278 TrackMapKeyPair.first = HLoc + LeftStep;
7279 TrackMapKeyPair.second = VLoc;
7280 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7289 TrainPresent =
true;
7303 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
7305 TrackMapKeyPair.first = HLoc + RightStep;
7306 TrackMapKeyPair.second = VLoc;
7307 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7316 TrainPresent =
true;
7336 for(
unsigned int x = 0; x < SearchVector.size(); x++)
7353 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7356 throw Exception(
"PlotSmallFlashingLinkedLevelCrossings");
7362 while(
IsLCAtHV(61, HLoc, (VLoc + UpStep)))
7369 while(
IsLCAtHV(62, HLoc, (VLoc + DownStep)))
7375 for(
int x = UpStep; x <= DownStep; x++)
7382 while(
IsLCAtHV(63, (HLoc + LStep), VLoc))
7389 while(
IsLCAtHV(64, (HLoc + RStep), VLoc))
7395 for(
int x = LStep; x <= RStep; x++)
7411 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
7418 else if(TrackElement.
SpeedTag < 132)
7436 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7453 AnsiString(ScreenPosV));
7468 AnsiString(ScreenPosV));
7479 AnsiString(VPosTrue));
7493 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7505 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7506 " in TrackMap, Caller=" + (AnsiString)Caller);
7508 if(MapVecPos != (
int)a)
7510 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7511 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
7512 (AnsiString)Caller);
7518 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7519 " Caller=" + (AnsiString)Caller);
7539 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7540 " in InactiveMap, Caller=" + (AnsiString)Caller);
7542 if((InactivePair.first != a) && (InactivePair.second != a))
7544 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7545 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
7546 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
7551 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7552 " Caller=" + (AnsiString)Caller);
7562 int Position1, Position2;
7568 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
7570 int HLoc1 = GapMapPtr->first.first;
7571 int VLoc1 = GapMapPtr->first.second;
7572 int HLoc2 = GapMapPtr->second.first;
7573 int VLoc2 = GapMapPtr->second.second;
7576 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
7580 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
7584 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
7588 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
7592 unsigned int GapCount = 0;
7594 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7602 if((
GapMap.size() * 2) != GapCount)
7604 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
7605 (AnsiString)Caller);
7615 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
7619 throw Exception(
"Error - TrackFinished with erase element still present");
7624 AnsiString IDString;
7626 if(TrackElement.
HLoc < 0)
7628 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
7632 IDString = AnsiString(TrackElement.
HLoc) +
"-";
7634 if(TrackElement.
VLoc < 0)
7636 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
7640 IDString += AnsiString(TrackElement.
VLoc);
7654 for(
int x = 1; x < String.Length() + 1; x++)
7656 if(String.IsDelimiter(
"-", x))
7661 if(x == String.Length())
7665 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
7675 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
7680 if(DelimPos == String.Length())
7684 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
7689 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
7693 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
7700 if(String.SubString(1, 1) !=
"N")
7702 for(
int x = 1; x < DelimPos; x++)
7704 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7708 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7715 if(String.SubString(1, 1) ==
"N")
7717 for(
int x = 2; x < DelimPos; x++)
7719 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7723 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7730 if(String.SubString(1, 1) ==
"N")
7732 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
7736 HLoc = String.SubString(1, DelimPos - 1).ToInt();
7738 if(String.SubString(DelimPos + 1, 1) !=
"N")
7740 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
7742 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7746 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7753 if(String.SubString(DelimPos + 1, 1) ==
"N")
7755 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
7757 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7761 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7768 if(String.SubString(DelimPos + 1, 1) ==
"N")
7770 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
7774 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
7779 TrackMapPtr =
TrackMap.find(HVPair);
7784 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
7790 return(TrackMapPtr->second);
7801 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
7802 int HLoc = TrackElement.
HLoc;
7803 int VLoc = TrackElement.
VLoc;
7906 AnsiString(SpeedTag));
7917 if(HVRange.first == HVRange.second)
7924 HVIt1 = HVRange.first;
7929 if(--HVRange.second != HVRange.first)
7931 HVIt2 = HVRange.second;
7935 HVIt2->second).
SpeedTag == SpeedTag)))
7955 AnsiString(SpeedTag));
8021 AnsiString TestString1, TestString2;
8026 throw Exception(
"LNPendingList size not 1 on entry");
8028 int CurrentElementNumber;
8034 int H = CurrentElement->HLoc;
8035 int V = CurrentElement->VLoc;
8036 int Tag = CurrentElement->SpeedTag;
8042 for(
int x = 0; x < 25; x++)
8052 for(
int x = 0; x < 25; x++)
8062 for(
int x = 0; x < 25; x++)
8072 for(
int x = 0; x < 25; x++)
8082 for(
int x = 0; x < 28; x++)
8092 for(
int x = 0; x < 8; x++)
8102 for(
int x = 0; x < 8; x++)
8112 for(
int x = 0; x < 4; x++)
8122 for(
int x = 0; x < 8; x++)
8132 for(
int x = 0; x < 8; x++)
8145 if(CurrentElementNumber > -1)
8150 if((ExistingName !=
"") && (ExistingName != LocationName))
8166 AddName(1, CurrentElement, LocationName);
8170 LNDone2MultiMapEntry.first = HVPair;
8181 bool FoundFlag, ErasedFlag =
false;
8183 if(SNRange.first != SNRange.second)
8187 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
8194 TVIt->LocationName =
"";
8195 TVIt->ActiveTrackElementName =
"";
8228 std::pair<AnsiString, char>TempMapPair;
8236 TempMapPair.second =
'x';
8254 AnsiString(SpeedTag));
8264 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
8271 int MapPos = -1 - Position;
8275 FoundElement = MapPos;
8291 FoundElement = IMPair.first;
8300 FoundElement = IMPair.second;
8321 AnsiString OldName = TrackElement->LocationName, ErrorString;
8323 TrackElement->LocationName = Name;
8324 int HLoc = TrackElement->HLoc;
8325 int VLoc = TrackElement->VLoc;
8339 if(ErrorString !=
"")
8341 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
8365 if(LNDone2MultiMapIterator->second == MapPos)
8392 if(*LNPendingListIterator == MapPos)
8465 if(NameBeingChecked !=
"")
8471 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8479 NameBeingChecked = LNMMRg.second->first;
8481 if(NameBeingChecked !=
"")
8487 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8508 if(LNMMIt->second < 0)
8518 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
8526 std::list<THVPair> HVLinkedList;
8529 HVPairsLinkedMap.begin()->second =
true;
8530 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
8533 THVPair HVPairUnderExamination;
8534 THVPairsLinkedMap::iterator HVPLMIt;
8536 while(!HVLinkedList.empty())
8538 HVPairUnderExamination = HVLinkedList.front();
8539 HVLinkedList.pop_front();
8540 HVPairNew.first = HVPairUnderExamination.first;
8541 HVPairNew.second = HVPairUnderExamination.second - 1;
8542 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8543 if(HVPLMIt != HVPairsLinkedMap.end())
8545 if(!HVPLMIt->second)
8547 HVLinkedList.push_back(HVPLMIt->first);
8549 HVPLMIt->second =
true;
8551 HVPairNew.first = HVPairUnderExamination.first - 1;
8552 HVPairNew.second = HVPairUnderExamination.second;
8553 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8554 if(HVPLMIt != HVPairsLinkedMap.end())
8556 if(!HVPLMIt->second)
8558 HVLinkedList.push_back(HVPLMIt->first);
8560 HVPLMIt->second =
true;
8562 HVPairNew.first = HVPairUnderExamination.first;
8563 HVPairNew.second = HVPairUnderExamination.second + 1;
8564 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8565 if(HVPLMIt != HVPairsLinkedMap.end())
8567 if(!HVPLMIt->second)
8569 HVLinkedList.push_back(HVPLMIt->first);
8571 HVPLMIt->second =
true;
8573 HVPairNew.first = HVPairUnderExamination.first + 1;
8574 HVPairNew.second = HVPairUnderExamination.second;
8575 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8576 if(HVPLMIt != HVPairsLinkedMap.end())
8578 if(!HVPLMIt->second)
8580 HVLinkedList.push_back(HVPLMIt->first);
8582 HVPLMIt->second =
true;
8587 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
8589 if(!HVPLMIt->second)
8608 if(LocationName ==
"")
8619 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8626 ActiveTrackElementNameMapEntry.second = 0;
8648 bool FoundFlag, ErasedFlag =
false;
8652 if(SNRange.first != SNRange.second)
8655 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
8658 TVIt->LocationName =
"";
8659 TVIt->ActiveTrackElementName =
"";
8693 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
8695 AnsiString LocationName;
8704 if(LocationName !=
"")
8712 if(LocationName !=
"")
8726 if(LocationName !=
"")
8728 int ModifiedPosition = -1 - Position;
8737 for(
int x = 0; x < 25; x++)
8747 else if(SpeedTag == 77)
8749 for(
int x = 0; x < 25; x++)
8759 else if(SpeedTag == 78)
8761 for(
int x = 0; x < 25; x++)
8771 else if(SpeedTag == 79)
8773 for(
int x = 0; x < 25; x++)
8783 else if(SpeedTag == 96)
8785 for(
int x = 0; x < 28; x++)
8795 else if(SpeedTag == 129)
8797 for(
int x = 0; x < 8; x++)
8807 else if(SpeedTag == 130)
8809 for(
int x = 0; x < 8; x++)
8819 else if(SpeedTag == 145)
8821 for(
int x = 0; x < 8; x++)
8831 else if(SpeedTag == 146)
8833 for(
int x = 0; x < 8; x++)
8843 else if(SpeedTag == 131)
8845 for(
int x = 0; x < 4; x++)
8868 AnsiString(SpeedTag));
8880 if(TempElement->LocationName !=
"")
8882 LocationName = TempElement->LocationName;
8883 FoundElement = IMPair.first;
8891 if(TempElement->LocationName !=
"")
8893 LocationName = TempElement->LocationName;
8894 FoundElement = IMPair.second;
8906 if(TempElement->LocationName !=
"")
8908 LocationName = TempElement->LocationName;
8909 FoundElement = -1 - Position;
8925 unsigned int Count = 0;
8932 AnsiString SName, TName, ErrorString;
8934 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8940 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
8941 AnsiString(Caller));
8954 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
8955 AnsiString(Caller));
8962 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
8963 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8968 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8974 if(ErrorString !=
"")
8976 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
8978 if(SNIt->second != -1 - (
int)x)
8980 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
8981 AnsiString(Caller));
8987 bool FoundFlag =
false;
8996 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackElementAt(1369, x).HLoc) +
" & V " +
8997 AnsiString(
TrackElementAt(1370, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9001 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackElementAt(1371, x).HLoc) +
9002 " & V " + AnsiString(
TrackElementAt(1372, x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
9003 AnsiString(Caller));
9008 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackElementAt(1373, x).HLoc) +
" & V " +
9009 AnsiString(
TrackElementAt(1374, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9019 if(ErrorString !=
"")
9021 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
9023 if(SNIt->second != (
int)x)
9025 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9026 AnsiString(Caller));
9036 AnsiString &ErrorString)
9044 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
9046 bool FoundFlag =
false;
9050 if(SNRange.first == SNRange.second)
9052 ErrorString =
"Error, Name " + LocationName +
" not found in map";
9054 return(SNRange.first);
9058 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9060 if(SNIterator->second < 0)
9062 int TVPos = -1 - SNIterator->second;
9064 if(TVIt == TrackElement)
9073 int ITVPos = SNIterator->second;
9075 if(ITVIt == TrackElement)
9086 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
9103 LocationNameEntry.first = NewName;
9104 LocationNameEntry.second = SNIterator->second;
9118 int TruePos = -1 - Position;
9122 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9132 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9155 InactiveTrack2MultiMapIterator++)
9157 if(InactiveTrack2MultiMapIterator->second > VecPos)
9159 InactiveTrack2MultiMapIterator->second--;
9167 LocationNameMultiMapIterator++)
9169 if(LocationNameMultiMapIterator->second < 0)
9173 if(LocationNameMultiMapIterator->second > (
int)VecPos)
9175 LocationNameMultiMapIterator->second--;
9197 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
9199 if(TrackMapIterator->second > VecPos)
9201 TrackMapIterator->second--;
9209 LocationNameMultiMapIterator++)
9211 if(LocationNameMultiMapIterator->second >= 0)
9217 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
9219 LocationNameMultiMapIterator->second++;
9223 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9229 if(TkEl.
Conn[0] ==
int(VecPos))
9234 if(TkEl.
Conn[0] >
int(VecPos))
9238 if(TkEl.
Conn[0] > -1)
9264 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
9270 LocationNameEntry.second = -1 - TVPos;
9281 LocationNameEntry.second = ITVPos;
9323 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9355 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9383 AnsiString((
short)FirstTrack));
9384 bool LengthDifferent =
false, SpeedDifferent =
false;
9391 int EXArray[16][2] =
9393 {2, 4}, {6, 2}, {8, 6}, {4, 8},
9394 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
9397 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
9398 Graphics::TBitmap *Bitmap;
9402 InLink = TrackElement.
Link[0];
9403 OutLink = TrackElement.
Link[1];
9407 InLink = TrackElement.
Link[2];
9408 OutLink = TrackElement.
Link[3];
9410 for(
int x = 0; x < 16; x++)
9412 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
9419 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
9438 else if(TrackElement.
SpeedTag == 54)
9442 else if(TrackElement.
SpeedTag == 55)
9453 else if(TrackElement.
SpeedTag == 58)
9457 else if(TrackElement.
SpeedTag == 59)
9462 else if(Index == 14)
9468 else if(TrackElement.
SpeedTag == 52)
9472 else if(TrackElement.
SpeedTag == 57)
9477 else if(Index == 15)
9483 else if(TrackElement.
SpeedTag == 53)
9487 else if(TrackElement.
SpeedTag == 56)
9501 if(LengthDifferent && SpeedDifferent)
9569 else if(LengthDifferent && !SpeedDifferent)
9716 AnsiString((
short)FirstTrack));
9717 LengthDifferent =
false;
9718 SpeedDifferent =
false;
9723 LengthDifferent =
true;
9727 SpeedDifferent =
true;
9729 if(LengthDifferent || SpeedDifferent)
9742 LengthDifferent =
true;
9746 SpeedDifferent =
true;
9748 if(LengthDifferent || SpeedDifferent)
9761 LengthDifferent =
true;
9765 SpeedDifferent =
true;
9767 if(LengthDifferent || SpeedDifferent)
9847 AnsiString TempName;
9848 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
9849 bool ForwardSet, ReverseSet;
9851 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9856 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9894 for(
int y = 0; y < 2; y++)
9925 StartElement = TempElement;
9926 StartVecPos = VecPos;
9930 StartEntryPos = 1 - Dir;
9939 VecPos = TempElement.
Conn[1 - EntryPos];
9940 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
9942 EntryPos = TempEntryPos;
9970 ForwardNumber = ((Count + 1) / 2) + 1;
9971 ReverseNumber = (Count - ForwardNumber) + 1;
9974 TempElement = StartElement;
9975 VecPos = StartVecPos;
9976 if(Count == ForwardNumber)
9981 if(Count == ReverseNumber)
9989 VecPos = TempElement.
Conn[1 - EntryPos];
9990 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
9992 EntryPos = TempEntryPos;
9994 if(Count == ForwardNumber)
9999 if(Count == ReverseNumber)
10011 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10147 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10203 if((TextH / 16) - 1 <
HLocMin)
10207 if((TextH / 16) + 1 >
HLocMax)
10211 if((TextV / 16) - 1 <
VLocMin)
10215 if((TextV / 16) + 1 >
VLocMax)
10245 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
10246 bool &UserGraphicFoundFlag)
10249 TUserGraphicVector::iterator UserGraphicPtr;
10251 UserGraphicFoundFlag =
false;
10258 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
10259 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
10261 UserGraphicItem = x;
10262 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
10263 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
10264 UserGraphicFoundFlag =
true;
10282 int SpeedTag = TrackElement.
SpeedTag;
10286 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
10335 return(GraphicOutput);
10343 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10346 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
10359 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
10360 " in InactiveTrackElementAt");
10371 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10373 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
10398 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10399 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10403 if(SNRange.first == SNRange.second)
10408 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10410 if(SNIterator->second < 0)
10420 HVPair.first = InactiveElement.
HLoc;
10421 HVPair.second = InactiveElement.
VLoc;
10425 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNamedLocationLongEnoughForSplit (1)");
10427 int TVPos =
TrackMap.find(HVPair)->second;
10430 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10436 FirstNamedExitPos = 0;
10438 SecondNamedElement =
TrackElementAt(561, FirstNamedElement.
Conn[FirstNamedExitPos]);
10440 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10441 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10444 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10446 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
10447 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10448 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10451 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10461 FirstNamedExitPos = 1;
10463 SecondNamedElement =
TrackElementAt(564, FirstNamedElement.
Conn[FirstNamedExitPos]);
10465 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10466 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10469 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10471 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
10472 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10473 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10476 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10492 int &FirstNamedLinkedElementPos,
int &SecondNamedLinkedElementPos)
10506 AnsiString(FirstNamedElementPos));
10507 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10508 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10510 SecondNamedElementPos = -1;
10511 FirstNamedLinkedElementPos = -1;
10512 SecondNamedLinkedElementPos = -1;
10516 if(SNRange.first == SNRange.second)
10521 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10523 if(SNIterator->second < 0)
10533 HVPair.first = InactiveElement.
HLoc;
10534 HVPair.second = InactiveElement.
VLoc;
10546 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in ThisNamedLocationLongEnoughForSplit (2)"
10550 int TVPos =
TrackMap.find(HVPair)->second;
10551 if(TVPos != FirstNamedElementPos)
10557 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10563 FirstNamedExitPos = 0;
10565 SecondNamedElement =
TrackElementAt(568, FirstNamedElement.
Conn[FirstNamedExitPos]);
10567 FirstNamedLinkedElement =
TrackElementAt(569, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10568 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10571 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10573 SecondNamedLinkedElement =
TrackElementAt(570, SecondNamedElement.
Conn[SecondNamedExitPos]);
10574 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10575 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10578 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10580 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10581 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10582 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10591 FirstNamedExitPos = 1;
10593 SecondNamedElement =
TrackElementAt(571, FirstNamedElement.
Conn[FirstNamedExitPos]);
10595 FirstNamedLinkedElement =
TrackElementAt(572, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10596 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10599 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10601 SecondNamedLinkedElement =
TrackElementAt(573, SecondNamedElement.
Conn[SecondNamedExitPos]);
10602 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10603 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10606 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10608 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10609 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10610 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10631 if(SNRange.first != SNRange.second)
10633 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10635 if(SNIterator->second < 0)
10657 "," + AnsiString(SpeedTag));
10668 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
10698 else if(SpeedTag == 69)
10724 else if(SpeedTag == 70)
10750 else if(SpeedTag == 71)
10787 AnsiString(NextEntryPos) +
"," + AnsiString(OwnTrainID));
10788 if(NextEntryPos < 0)
10801 if(NextEntryPos > 1)
10820 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
10832 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
10833 bool FoundFlag =
false;
10848 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
10849 bool FoundFlag =
false;
10874 VPosHi = 16 * VLocHi;
10875 VPosLo = 16 * VLocLo;
10894 AnsiString(EndTVPosition));
10905 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
10906 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
10907 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
10908 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
10910 if(Link0Squares <= Link1Squares)
10928 AnsiString(LinkPos));
10947 if((LinkPos == 1) && (TE.
Attribute == 0))
10952 else if(LinkPos == 1)
10958 else if((LinkPos == 3) && (TE.
Attribute == 1))
10963 else if(LinkPos == 3)
10970 else if(LinkPos == 0)
10975 else if(LinkPos == 1)
10980 else if(LinkPos == 2)
10985 else if(LinkPos == 3)
10990 throw Exception(
"Error, failure in GetExitPos");
11039 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
11043 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
11085 "," + AnsiString(DiagonalLinkNumber));
11090 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
11095 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
11100 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
11105 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
11121 AnsiString JustFileName =
"";
11126 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
11133 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
11152 typedef std::list<int> TNamePosList;
11153 TNamePosList NamePosList;
11154 typedef TNamePosList::iterator TNPLIt;
11156 typedef std::list<int> TOnePlatList;
11157 TOnePlatList OnePlatList;
11158 typedef TOnePlatList::iterator TOPLIt;
11161 NamePosList.clear();
11162 OnePlatList.clear();
11163 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11165 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
11167 NamePosList.push_back(x);
11172 if(!NamePosList.empty())
11174 OnePlatList.push_back(NamePosList.back());
11175 NamePosList.pop_back();
11177 while(!OnePlatList.empty())
11179 TempInt = OnePlatList.front();
11182 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
11183 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
11185 OnePlatList.push_back(TempElement.
Conn[0]);
11186 NamePosList.erase(NPLIt);
11188 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
11189 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
11191 OnePlatList.push_back(TempElement.
Conn[1]);
11192 NamePosList.erase(NPLIt);
11195 OnePlatList.erase(OnePlatList.begin());
11196 if(OnePlatList.empty())
11199 if(!NamePosList.empty())
11201 OnePlatList.push_back(NamePosList.back());
11202 NamePosList.pop_back();
11219 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
11234 throw Exception(
"Return value negative in call to LastElementNumber");
11246 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
11260 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
11272 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
11273 " in GetModifiablePrefDirElementAt");
11283 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11285 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
11295 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11297 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
11314 int TrackVectorPosition;
11366 FinishElement =
false;
11367 int TrackVectorPosition;
11389 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
11399 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
11422 for(
int x = 0; x < 4; x++)
11445 FinishElement =
true;
11453 for(
int x = 0; x < 4; x++)
11465 FinishElement =
true;
11473 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11480 .ELinkPos] ==
Lead))
11496 FinishElement =
true;
11515 FinishElement =
true;
11534 FinishElement =
true;
11549 FinishElement =
true;
11558 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11574 FinishElement =
true;
11580 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11603 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
11604 int VectorCount = 0;
11608 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
11610 for(
int x = 0; x < VectorCount; x++)
11617 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
11621 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
11622 SearchElement.
ELinkPos = NextELinkPos;
11643 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
11645 SearchElement.
XLinkPos = NextXLinkPos;
11671 for(
int x = 0; x < VectorCount; x++)
11683 for(
int x = 0; x < VectorCount; x++)
11697 for(
int x = 0; x < VectorCount; x++)
11711 for(
int x = 0; x < VectorCount; x++)
11721 for(
int x = 0; x < VectorCount; x++)
11732 SearchElement.
XLink = SearchElement.
Link[1];
11751 SearchElement.
XLink = SearchElement.
Link[3];
11764 for(
int x = 0; x < VectorCount; x++)
11779 XLinkPos = NextXLinkPos;
11780 CurrentTrackElement = SearchElement;
11799 throw Exception(
"Error, SearchVector empty");
11806 for(
int x = 0; x < 4; x++)
11859 throw Exception(
"Error in EntryExitNumber 1");
11878 if(PrefDirElement.
XLink == -1)
11890 if(PrefDirElement.
XLink != -1)
11894 throw Exception(
"Error in EntryExitNumber 2");
11932 LeadingPoints =
false;
11960 LeadingPoints =
true;
11976 AnsiString ErrorString;
11977 bool Error =
false;
11984 ErrorString =
"HLoc";
11990 ErrorString =
"VLoc";
11996 ErrorString =
"ELink";
12002 ErrorString =
"ELinkPos";
12008 ErrorString =
"XLink";
12014 ErrorString =
"XLinkPos";
12020 ErrorString =
"Tag";
12026 ErrorString =
"TrackVectorPosition";
12032 ErrorString =
"EXNumber";
12039 ErrorString =
"CheckCount";
12046 ErrorString =
"EntryGraphicPtr";
12052 ErrorString =
"EntryDirectionGraphicPtr";
12061 ErrorString =
"Last XLink not connected to this element";
12068 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
12092 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
12149 AnsiString((
short)BuildingPrefDir));
12152 if(PrefDirSize() == 0)
12157 for(
unsigned int x = 0; x < PrefDirSize(); x++)
12169 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
12181 if(x == (PrefDirSize() - 1))
12190 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
12192 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
12193 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
12194 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
12196 if(PrefDirSize() > 1)
12198 unsigned int LatestPos = PrefDirSize() - 1;
12199 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
12200 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
12201 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
12222 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12225 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12229 H = MMIT->first.first;
12230 V = MMIT->first.second;
12233 if(PrefDirPos0 > -1)
12237 if(PrefDirPos1 > -1)
12241 if(PrefDirPos2 > -1)
12245 if(PrefDirPos3 > -1)
12249 if(PrefDirPos3 > -1)
12265 else if(PrefDirPos2 > -1)
12307 else if(PrefDirPos1 > -1)
12330 else if(PrefDirPos0 > -1)
12349 int NumberOfPrefDirElements = 0;
12352 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12354 VecFile >> TempInt;
12357 VecFile >> TempInt;
12358 LoadPrefDirElement.
ELink = TempInt;
12359 VecFile >> TempInt;
12360 LoadPrefDirElement.
ELinkPos = TempInt;
12361 VecFile >> TempInt;
12362 LoadPrefDirElement.
XLink = TempInt;
12363 VecFile >> TempInt;
12364 LoadPrefDirElement.
XLinkPos = TempInt;
12365 VecFile >> TempInt;
12366 LoadPrefDirElement.
EXNumber = TempInt;
12367 VecFile >> TempInt;
12372 if(!(LoadPrefDirElement.
IsARoute))
12398 int NumberOfPrefDirElements = 0;
12401 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12403 VecFile >> TempInt;
12404 VecFile >> TempInt;
12407 VecFile >> TempInt;
12408 LoadPrefDirElement.
ELink = TempInt;
12409 VecFile >> TempInt;
12410 LoadPrefDirElement.
ELinkPos = TempInt;
12411 VecFile >> TempInt;
12412 LoadPrefDirElement.
XLink = TempInt;
12413 VecFile >> TempInt;
12414 LoadPrefDirElement.
XLinkPos = TempInt;
12415 VecFile >> TempInt;
12416 LoadPrefDirElement.
EXNumber = TempInt;
12417 VecFile >> TempInt;
12422 if(!(LoadPrefDirElement.
IsARoute))
12450 int NumberOfPrefDirElements = 0;
12453 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
12458 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12465 VecFile >> TempInt;
12466 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
12471 VecFile >> TempInt;
12472 if((TempInt < -1) || (TempInt > 9))
12477 VecFile >> TempInt;
12478 if((TempInt < -1) || (TempInt > 3))
12483 VecFile >> TempInt;
12484 if((TempInt < -1) || (TempInt > 9))
12489 VecFile >> TempInt;
12490 if((TempInt < -1) || (TempInt > 3))
12495 VecFile >> TempInt;
12496 if((TempInt < -1) || (TempInt > 27))
12501 VecFile >> TempInt;
12509 VecFile >> TempInt;
12510 if((TempInt != 0) && (TempInt != 1))
12515 VecFile >> TempInt;
12516 if((TempInt != 0) && (TempInt != 1))
12521 VecFile >> TempInt;
12522 if((TempInt != 0) && (TempInt != 1))
12545 for(
int y = 0; y < NumberOfPrefDirElements; y++)
12547 VecFile << y <<
'\n';
12548 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
12558 if(y == (NumberOfPrefDirElements - 1))
12560 VecFile <<
"************" <<
'\0' <<
'\n';
12564 VecFile <<
"******" <<
'\0' <<
'\n';
12578 for(
int y = 0; y < NumberOfSearchElements; y++)
12580 VecFile << y <<
'\n';
12581 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
12591 if(y == (NumberOfSearchElements - 1))
12593 VecFile <<
"************" <<
'\0' <<
'\n';
12597 VecFile <<
"******" <<
'\0' <<
'\n';
12710 bool AlreadyPresent, FoundFlag;
12711 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12713 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
12717 AlreadyPresent =
false;
12722 AlreadyPresent =
true;
12726 AlreadyPresent =
true;
12730 AlreadyPresent =
true;
12734 AlreadyPresent =
true;
12737 if(!AlreadyPresent)
12784 for(
unsigned int z = 0; z < 4; z++)
12792 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
12806 bool DiscrepancyFound =
false;
12817 DiscrepancyFound =
true;
12822 DiscrepancyFound =
true;
12827 DiscrepancyFound =
true;
12832 DiscrepancyFound =
true;
12837 DiscrepancyFound =
true;
12843 DiscrepancyFound =
true;
12846 if(DiscrepancyFound)
12848 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
12863 bool DiscrepancyFound =
false;
12874 DiscrepancyFound =
true;
12878 DiscrepancyFound =
true;
12883 DiscrepancyFound =
true;
12888 DiscrepancyFound =
true;
12893 DiscrepancyFound =
true;
12899 DiscrepancyFound =
true;
12903 return(!DiscrepancyFound);
12915 bool FoundFlag =
false;
12916 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
12924 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
12925 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
12927 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
12929 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
12930 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
12931 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
12936 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
12937 +
" Caller=" + (AnsiString)Caller);
12963 PrefDirMapKeyPair.first = HLoc;
12964 PrefDirMapKeyPair.second = VLoc;
12965 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12968 if(ItPair.first == ItPair.second)
12976 PrefDirPos0 = ItPair.first->second;
12978 if(ItPair.first == ItPair.second)
12983 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
12985 PrefDirPos1 = ItPair.first->second;
12988 if(ItPair.first == ItPair.second)
12993 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
12995 PrefDirPos2 = ItPair.first->second;
12998 if(ItPair.first == ItPair.second)
13003 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13005 PrefDirPos3 = ItPair.first->second;
13020 +
"," + AnsiString(LinkNumberPos));
13022 int PD0, PD1, PD2, PD3;
13023 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
13027 PD0, PD1, PD2, PD3);
13039 LinkedPrefDirVectorNumber = PD0;
13048 LinkedPrefDirVectorNumber = PD1;
13058 LinkedPrefDirVectorNumber = PD0;
13067 LinkedPrefDirVectorNumber = PD1;
13076 LinkedPrefDirVectorNumber = PD2;
13085 LinkedPrefDirVectorNumber = PD3;
13090 LinkedPrefDirVectorNumber = -1;
13096 LinkedPrefDirVectorNumber = -1;
13101 catch(
const Exception &e)
13103 LinkedPrefDirVectorNumber = -1;
13115 int PD0, PD1, PD2, PD3;
13167 THVPair PrefDir4MultiMapKeyPair;
13170 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
13171 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
13172 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
13195 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
13214 AnsiString(ErasedElementNumber));
13219 if(MapPtr->second > ErasedElementNumber)
13241 throw Exception(
"PrefDirVectorPosition out of range");
13244 THVPair PrefDir4MultiMapKeyPair;
13246 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
13247 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
13248 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13251 if(ItPair.first == ItPair.second)
13254 return(ItPair.first);
13258 if(ItPair.first->second == PrefDirVectorPosition)
13262 return(ItPair.first);
13265 if(ItPair.first == ItPair.second)
13268 return(ItPair.first);
13270 if(ItPair.first->second == PrefDirVectorPosition)
13274 return(ItPair.first);
13277 if(ItPair.first == ItPair.second)
13280 return(ItPair.first);
13282 if(ItPair.first->second == PrefDirVectorPosition)
13286 return(ItPair.first);
13289 if(ItPair.first == ItPair.second)
13292 return(ItPair.first);
13294 if(ItPair.first->second == PrefDirVectorPosition)
13298 return(ItPair.first);
13302 return(ItPair.first);
13315 THVPair PrefDir4MultiMapKeyPair;
13317 PrefDir4MultiMapKeyPair.first = HLoc;
13318 PrefDir4MultiMapKeyPair.second = VLoc;
13319 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13322 if(ItPair.first == ItPair.second)
13330 return(ItPair.first->second);
13339 bool ErasedFlag =
false;
13341 if(ErasedTrackVectorPosition > -1)
13350 ErasedFlag =
false;
13352 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
13357 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
13362 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
13367 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
13372 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
13380 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
13384 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
13388 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
13392 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
13396 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
13411 OverallDistance = 0;
13412 OverallSpeedLimit = 0;
13413 LeadingPointsAtLastElement =
false;
13421 LeadingPointsAtLastElement =
true;
13430 OverallDistance += PrefDirElement.
Length23;
13431 if(OverallSpeedLimit != -1)
13441 OverallSpeedLimit = -1;
13448 OverallDistance += PrefDirElement.
Length01;
13449 if(OverallSpeedLimit != -1)
13459 OverallSpeedLimit = -1;
13478 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13481 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
13485 HLoc = MMIT->first.first;
13486 VLoc = MMIT->first.second;
13491 if(PrefDirPos0 > -1)
13495 if(PrefDirPos1 > -1)
13499 if(PrefDirPos2 > -1)
13503 if(PrefDirPos3 > -1)
13507 if(PrefDirPos3 > -1)
13510 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
13512 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
13514 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
13516 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
13523 else if(PrefDirPos2 > -1)
13528 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
13530 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
13532 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
13541 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
13543 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
13545 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
13554 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
13556 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
13558 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
13565 else if(PrefDirPos1 > -1)
13570 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
13572 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
13580 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
13582 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
13588 else if(PrefDirPos0 > -1)
13590 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
13607 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13610 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
13631 if(PrefDirPos0 > -1)
13635 if(PrefDirPos1 > -1)
13639 if(PrefDirPos2 > -1)
13643 if(PrefDirPos3 > -1)
13647 if(PrefDirPos3 > -1)
13652 else if(PrefDirPos2 > -1)
13654 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
13665 else if(PrefDirPos1 > -1)
13667 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
13678 else if(PrefDirPos0 > -1)
13680 if(PrefDirElement0.
XLinkPos == EntryPos)
13717 ElementIn.
VLoc +
"," + XLink);
13719 bool TrackFoundFlag;
13722 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
13734 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
13744 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
13758 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
13768 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
13782 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
13792 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
13806 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
13816 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
13839 bool FoundFlag, ContFlag, FoundElements =
false;
13840 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13845 LastIteratorValue++;
13870 if(PDVIt->XLinkPos == 0)
13875 StartElement = *PDVIt;
13884 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
13886 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
13887 if(PrefDirPos0 == -1)
13891 bool NextElementFoundFlag =
false;
13895 NextElementFoundFlag =
true;
13897 if(PrefDirPos1 > -1)
13902 NextElementFoundFlag =
true;
13905 if(PrefDirPos2 > -1)
13910 NextElementFoundFlag =
true;
13913 if(PrefDirPos3 > -1)
13918 NextElementFoundFlag =
true;
13921 if(!NextElementFoundFlag)
13951 EndElement = NextElement;
13955 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
13957 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
13958 if(PrefDirPos0 == -1)
13968 if(PrefDirPos1 > -1)
13976 if(PrefDirPos2 > -1)
13984 if(PrefDirPos3 > -1)
14015 FoundElements =
true;
14049 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
14051 int TrackVectorPosition;
14087 int LockedVectorNumber;
14110 bool InPrefDirFlag =
false;
14113 int PrefDirPos0 = -1;
14114 int PrefDirPos1 = -1;
14115 int PrefDirPos2 = -1;
14116 int PrefDirPos3 = -1;
14120 int PrefDirVecPos[4] =
14122 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14125 for(
int x = 0; x < 4; x++)
14127 int b = PrefDirVecPos[x];
14137 InPrefDirFlag =
true;
14151 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14159 if(DummyPair.first > -1)
14161 throw Exception(
"Selection in two routes - should never happen!");
14163 if(RoutePair.first > -1)
14239 IDInt &ReqPosRouteID,
bool &PointsChanged)
14273 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
14323 bool InPrefDirFlag =
false;
14326 int PrefDirPos0 = -1;
14327 int PrefDirPos1 = -1;
14328 int PrefDirPos2 = -1;
14329 int PrefDirPos3 = -1;
14332 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14333 int PrefDirVecPos[4] =
14335 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14338 for(
int x = 0; x < 4; x++)
14340 int b = PrefDirVecPos[x];
14343 InPrefDirFlag =
true;
14357 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14366 if(RoutePair.first > -1)
14368 if(RoutePair.second != 0)
14385 EndElement1 = RouteElement;
14386 EndElement2 = BlankElement;
14486 PointsChanged =
true;
14514 PointsChanged =
true;
14537 PointsChanged =
true;
14566 PointsChanged =
true;
14580 PointsChanged =
true;
14599 PointsChanged =
true;
14613 PointsChanged =
true;
14629 PointsChanged =
true;
14683 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag)
14736 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
14737 AnsiString((
short)AutoSigsFlag));
14738 int VectorCount = 0;
14742 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
14746 for(
int x = 0; x < VectorCount; x++)
14754 bool FirstPass =
true;
14764 for(
int x = 0; x < VectorCount; x++)
14773 for(
int x = 0; x < VectorCount; x++)
14785 for(
int x = 0; x < VectorCount; x++)
14793 int NextPosition = PrefDirElement.
Conn[XLinkPos];
14797 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
14798 SearchElement.
ELinkPos = NextELinkPos;
14799 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
14820 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
14822 SearchElement.
XLinkPos = NextXLinkPos;
14834 for(
int x = 0; x < VectorCount; x++)
14848 if(RoutePair.first > -1)
14857 for(
int x = 0; x < VectorCount; x++)
14866 if(SecondPair.first > -1)
14875 for(
int x = 0; x < VectorCount; x++)
14889 for(
int x = 0; x < VectorCount; x++)
14900 for(
int x = 0; x < VectorCount; x++)
14909 for(
int x = 0; x < VectorCount; x++)
14918 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
14922 for(
int x = 0; x < VectorCount; x++)
14932 bool InPrefDirFlag =
false;
14933 PrefDirElement1 = BlankElement;
14934 PrefDirElement2 = BlankElement;
14937 int PrefDirPos0 = -1;
14938 int PrefDirPos1 = -1;
14939 int PrefDirPos2 = -1;
14940 int PrefDirPos3 = -1;
14943 int PrefDirVecPos[4] =
14945 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14947 for(
int x = 0; x < 4; x++)
14949 int b = PrefDirVecPos[x];
14952 InPrefDirFlag =
true;
14965 for(
int x = 0; x < VectorCount; x++)
14977 for(
int x = 0; x < VectorCount; x++)
14993 for(
int x = 0; x < VectorCount; x++)
15013 for(
int x = 0; x < VectorCount; x++)
15030 for(
int x = 0; x < VectorCount; x++)
15040 for(
int x = 0; x < VectorCount; x++)
15051 int SearchPos1 = SearchElement.
Attribute + 1;
15053 if(SearchPos1 == 2)
15057 if(SearchPos1 == 1)
15065 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
15066 SearchElement.
XLinkPos = SearchPos1;
15067 InPrefDirFlag =
false;
15068 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15070 SearchElement = PrefDirElement1;
15071 InPrefDirFlag =
true;
15073 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15075 SearchElement = PrefDirElement2;
15076 InPrefDirFlag =
true;
15082 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15086 for(
int x = 0; x < VectorCount; x++)
15113 for(
int x = 0; x < VectorCount; x++)
15131 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
15132 SearchElement.
XLinkPos = SearchPos2;
15133 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15135 SearchElement = PrefDirElement1;
15137 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15139 SearchElement = PrefDirElement2;
15143 for(
int x = 0; x < VectorCount; x++)
15151 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15155 for(
int x = 0; x < VectorCount; x++)
15183 for(
int x = 0; x < VectorCount; x++)
15195 for(
int x = 0; x < VectorCount; x++)
15205 SearchElement = PrefDirElement1;
15214 XLinkPos = SearchElement.
XLinkPos;
15215 PrefDirElement = SearchElement;
15272 unsigned int TruncatePrefDirPosition = 0;
15345 throw Exception(
"Error - failed to validate extended route for preferred route");
15400 throw Exception(
"Error - failed to validate single route for preferred route");
15445 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
15447 int TrackVectorPosition;
15484 int LockedVectorNumber;
15518 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
15519 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
15522 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
15528 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
15529 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
15532 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
15546 if(RoutePair.first > -1)
15744 EndElement1.
ELink = EndElement1.
Link[0];
15745 EndElement1.
XLink = EndElement1.
Link[1];
15748 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
15753 EndElement2.
ELink = EndElement2.
Link[1];
15754 EndElement2.
XLink = EndElement2.
Link[0];
15757 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
15801 if(RoutePair.first > -1)
15803 if(RoutePair.second != 0)
15826 EndElement2 = BlankElement;
15911 PointsChanged =
true;
15937 PointsChanged =
true;
15959 PointsChanged =
true;
15985 PointsChanged =
true;
15999 PointsChanged =
true;
16039 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
16040 int VectorCount = 0;
16043 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
16044 (CurrentTrackElement.
Link[XLinkPos] == 9))
16048 for(
int x = 0; x < VectorCount; x++)
16060 for(
int x = 0; x < VectorCount; x++)
16067 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
16069 for(
int x = 0; x < VectorCount; x++)
16076 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
16080 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
16081 SearchElement.
ELinkPos = NextELinkPos;
16102 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
16104 SearchElement.
XLinkPos = NextXLinkPos;
16117 for(
int x = 0; x < VectorCount; x++)
16131 if(RoutePair.first > -1)
16140 for(
int x = 0; x < VectorCount; x++)
16149 if(SecondPair.first > -1)
16158 for(
int x = 0; x < VectorCount; x++)
16172 for(
int x = 0; x < VectorCount; x++)
16183 for(
int x = 0; x < VectorCount; x++)
16192 for(
int x = 0; x < VectorCount; x++)
16201 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16205 for(
int x = 0; x < VectorCount; x++)
16218 for(
int x = 0; x < VectorCount; x++)
16250 for(
int x = 0; x < VectorCount; x++)
16260 for(
int x = 0; x < VectorCount; x++)
16271 int SearchPos1 = SearchElement.
Attribute + 1;
16273 if(SearchPos1 == 2)
16277 if(SearchPos1 == 1)
16286 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
16287 SearchElement.
XLinkPos = SearchPos1;
16289 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16293 for(
int x = 0; x < VectorCount; x++)
16318 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
16319 SearchElement.
XLinkPos = SearchPos2;
16321 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16325 for(
int x = 0; x < VectorCount; x++)
16344 for(
int x = 0; x < VectorCount; x++)
16359 CurrentTrackElement = SearchElement;
16360 XLinkPos = SearchElement.
XLinkPos;
16382 throw Exception(
"Error, SearchVector empty");
16394 for(
int x = 0; x < 4; x++)
16436 throw Exception(
"Error in EntryExitNumber 3");
16491 unsigned int TruncatePrefDirPosition = 0;
16551 throw Exception(
"Failed to validate extended route for nonpreferred route");
16596 throw Exception(
"Failed to validate single route for nonpreferred route");
16616 if(!PrefDirVector.empty())
16620 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
16625 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
16660 if(!PrefDirVector.empty())
16663 TPrefDirElement LastElement = GetFixedPrefDirElementAt(185, PrefDirSize() - 1);
16665 int ForwardLinkedRouteNumber, Attribute = 0;
16672 if(ForwardLinkedRouteNumber > -1)
16674 int NextForwardLinkedRouteNumber = -1;
16678 ForwardLinkedRouteNumber = NextForwardLinkedRouteNumber;
16688 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
16708 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
16716 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
16747 NextForwardLinkedRouteNumber = -1;
16748 for(
unsigned int x = 0; x < PrefDirSize(); x++)
16750 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
16751 if(PrefDirVector.at(x).TrackType ==
Bridge)
16753 if(PrefDirVector.at(x).XLinkPos < 2)
16755 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos01;
16759 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos23;
16767 if(PrefDirVector.at(x).TrackType ==
Buffers)
16779 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
16788 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
16790 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute + 1;
16798 if(x == PrefDirSize() - 1)
16842 AnsiString(PrefDirVectorStartPosition));
16847 bool SkipContinuationAndBufferAttributeChange =
false;
16849 if(!PrefDirVector.empty())
16851 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
16854 if(PrefDirPtr->TrackType ==
Bridge)
16856 if(PrefDirPtr->XLinkPos < 2)
16867 SkipContinuationAndBufferAttributeChange =
true;
16882 SkipContinuationAndBufferAttributeChange =
true;
16890 SkipContinuationAndBufferAttributeChange =
true;
16892 if(!SkipContinuationAndBufferAttributeChange)
16894 if(PrefDirVector.back().TrackType ==
Buffers)
16903 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
16906 if(PrefDirPtr->TrackType ==
Bridge)
16908 if(PrefDirPtr->XLinkPos < 2)
16924 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
16933 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
16935 if((!
AllRoutes->
RouteTruncateFlag) || (PrefDirPtr != (PrefDirVector.begin() + PrefDirVectorStartPosition)) || PrefDirPtr->AutoSignals ||
16936 PrefDirPtr->PrefDirRoute)
16940 int LockedVecNum = 0;
16942 bool KeepAttributeAt0ForLockedRoute =
false;
16947 KeepAttributeAt0ForLockedRoute =
true;
16967 if((Attribute < 3) && !KeepAttributeAt0ForLockedRoute)
16995 "," + AnsiString((
short)PrefDirRoute));
16996 bool ElementInRoute =
false;
16997 bool TrainOccupyingRoute =
false;
17003 ElementInRoute =
true;
17007 if(!ElementInRoute)
17035 TrainOccupyingRoute =
true;
17102 if(LRVIT->RouteNumber == RouteNumber)
17116 int button = Application->MessageBox(L
"Train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
17117 L
"Warning!", MB_YESNO | MB_ICONWARNING);
17129 bool ExistingLockedRouteModified =
false;
17142 if(LRVIT->RouteNumber == RouteNumber)
17146 ExistingLockedRouteModified =
true;
17150 if(!ExistingLockedRouteModified)
17240 AnsiString((
short)PrefDirRoute));
17265 AnsiString((
short)PrefDirRoute));
17275 RouteFlashElement.
HLoc = H;
17276 RouteFlashElement.
VLoc = V;
17292 int H = PrefDirPtr->HLoc;
17293 int V = PrefDirPtr->VLoc;
17360 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
17366 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
17369 OverlayPlotted =
false;
17379 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
17381 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
17384 return(AllRoutesVector.at(At));
17393 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
17395 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
17398 return(AllRoutesVector.at(At));
17409 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
17411 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
17421 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
17423 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
17441 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
17442 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
17445 RouteTruncateFlag =
true;
17447 GetModifiableRouteAt(7, a).GetRouteTruncateElement(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
17448 RouteTruncateFlag =
false;
17477 AnsiString(LinkPos));
17478 if(TrackVectorPosition == -1)
17483 THVPair Route2MultiMapKeyPair;
17487 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
17490 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
17500 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
17502 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
17505 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
17506 Route2MultiMapIterator->second.second);
17507 EntryLinkPos = PrefDirElement1.
ELinkPos;
17508 ExitLinkPos = PrefDirElement1.
XLinkPos;
17509 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
17510 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
17522 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
17534 Graphics::TBitmap* &EntryDirectionGraphicPtr)
17544 AnsiString(LinkPos));
17547 if(TrackVectorPosition == -1)
17552 THVPair Route2MultiMapKeyPair;
17556 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
17559 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
17564 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
17566 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
17568 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
17569 Route2MultiMapIterator->second.second);
17570 EntryLinkPos = PrefDirElement1.
ELinkPos;
17571 ExitLinkPos = PrefDirElement1.
XLinkPos;
17572 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
17573 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
17577 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
17578 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
17585 return(AutoSigsRoute);
17590 return(NotAutoSigsRoute);
17596 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
17597 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
17604 return(AutoSigsRoute);
17609 return(NotAutoSigsRoute);
17613 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
17615 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
17616 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
17618 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
17619 EntryLinkPos = PrefDirElement2.
ELinkPos;
17620 ExitLinkPos = PrefDirElement2.
XLinkPos;
17621 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
17622 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
17626 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
17633 return(AutoSigsRoute);
17638 return(NotAutoSigsRoute);
17644 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
17651 return(AutoSigsRoute);
17656 return(NotAutoSigsRoute);
17660 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
17661 EntryLinkPos = PrefDirElement3.
ELinkPos;
17662 ExitLinkPos = PrefDirElement3.
XLinkPos;
17663 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
17664 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
17668 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
17675 return(AutoSigsRoute);
17680 return(NotAutoSigsRoute);
17686 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
17693 return(AutoSigsRoute);
17698 return(NotAutoSigsRoute);
17714 AnsiString(LinkPos));
17715 if(TrackVectorPosition == -1)
17721 THVPair Route2MultiMapKeyPair;
17725 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
17728 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
17734 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
17736 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
17738 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
17739 Route2MultiMapIterator->second.second);
17740 EntryLinkPos = PrefDirElement1.
ELinkPos;
17741 ExitLinkPos = PrefDirElement1.
XLinkPos;
17742 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
17743 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
17746 RouteNumber = Route2MultiMapIterator->second.first;
17750 return(AutoSigsRoute);
17755 return(NotAutoSigsRoute);
17760 RouteNumber = Route2MultiMapIterator->second.first;
17764 return(AutoSigsRoute);
17769 return(NotAutoSigsRoute);
17773 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
17775 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
17776 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
17778 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
17779 EntryLinkPos = PrefDirElement2.
ELinkPos;
17780 ExitLinkPos = PrefDirElement2.
XLinkPos;
17781 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
17782 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
17785 RouteNumber = ItPair.first->second.first;
17789 return(AutoSigsRoute);
17794 return(NotAutoSigsRoute);
17799 RouteNumber = ItPair.first->second.first;
17803 return(AutoSigsRoute);
17808 return(NotAutoSigsRoute);
17812 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
17813 EntryLinkPos = PrefDirElement3.
ELinkPos;
17814 ExitLinkPos = PrefDirElement3.
XLinkPos;
17815 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
17816 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
17819 RouteNumber = ItPair.second->second.first;
17823 return(AutoSigsRoute);
17828 return(NotAutoSigsRoute);
17833 RouteNumber = ItPair.second->second.first;
17837 return(AutoSigsRoute);
17842 return(NotAutoSigsRoute);
17864 EmptyRoute.
RouteID = NextRouteID;
17867 AllRoutesVector.push_back(EmptyRoute);
17868 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
17893 AllRoutesVector.push_back(EmptyRoute);
17894 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
17917 THVPair Route2MultiMapKeyPair;
17926 LockedRouteTruncateTrackVectorPosition = 0;
17927 LockedRouteLastTrackVectorPosition = 0;
17928 LockedRouteLastXLinkPos = 0;
17929 LockedRouteLockStartTime = TDateTime(0);
17930 if(!LockedRouteVector.empty())
17934 if(LRVIT->RouteNumber == RouteNumber)
17936 LockedRouteTruncateTrackVectorPosition = LRVIT->TruncateTrackVectorPosition;
17937 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
17938 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
17939 LockedRouteLockStartTime = LRVIT->LockStartTime;
17940 LockedRouteFoundDuringRouteBuilding =
true;
17941 LockedRouteVector.erase(LRVIT);
17966 AnsiString(VLoc) +
"," + AnsiString(ELink));
17969 ReturnPair.first = -1;
17970 ReturnPair.second = 0;
17971 THVPair Route2MultiMapKeyPair;
17973 Route2MultiMapKeyPair.first = HLoc;
17974 Route2MultiMapKeyPair.second = VLoc;
17977 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
17978 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
17980 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
17981 Route2MultiMapIterator = ItPair.first;
17983 if(ItPair.first == ItPair.second)
17985 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
17987 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
17989 ReturnPair.first = ItPair.first->second.first;
17990 ReturnPair.second = ItPair.first->second.second;
17991 Route2MultiMapIterator = ItPair.first;
17993 return(ReturnPair);
17996 if(ItPair.first == ItPair.second)
17998 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
18000 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
18002 ReturnPair.first = ItPair.first->second.first;
18003 ReturnPair.second = ItPair.first->second.second;
18004 Route2MultiMapIterator = ItPair.first;
18006 return(ReturnPair);
18009 return(ReturnPair);
18024 AnsiString(VLoc) +
"," + AnsiString(ELink));
18025 THVPair Route2MultiMapKeyPair;
18027 Route2MultiMapKeyPair.first = HLoc;
18028 Route2MultiMapKeyPair.second = VLoc;
18029 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
18031 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
18033 if(ItPair.first == ItPair.second)
18039 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
18041 RouteNumber = ItPair.first->second.first;
18047 if(ItPair.first == ItPair.second)
18053 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
18055 RouteNumber = ItPair.first->second.first;
18076 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
18077 THVPair Route2MultiMapKeyPair;
18079 Route2MultiMapKeyPair.first = HLoc;
18080 Route2MultiMapKeyPair.second = VLoc;
18083 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
18086 RouteElementPair.first = RouteNumber;
18087 RouteElementPair.second = RouteElementNumber;
18088 Route2MultiMapEntry.second = RouteElementPair;
18090 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
18093 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
18094 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
18097 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
18098 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
18100 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
18102 Route2MultiMap.insert(Route2MultiMapEntry);
18107 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
18112 Route2MultiMap.insert(Route2MultiMapEntry);
18130 TempPair.first = -1;
18131 TempPair.second = 0;
18132 SecondPair = TempPair;
18134 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
18135 THVPair Route2MultiMapKeyPair;
18137 Route2MultiMapKeyPair.first = HLoc;
18138 Route2MultiMapKeyPair.second = VLoc;
18139 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
18144 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
18146 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
18148 return(Route2MultiMapIterator->second);
18150 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
18152 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
18153 TempPair = ItRange.first->second;
18154 SecondPair = (--ItRange.second)->second;
18177 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
18178 if(RouteElementPair.first == -1)
18181 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
18182 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
18184 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
18187 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
18188 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
18189 (AnsiString)Caller);
18191 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
18194 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
18195 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
18196 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
18197 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
18201 unsigned int SizeVal = 0;
18204 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18206 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
18208 if(SizeVal != Route2MultiMap.size())
18210 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
18211 (AnsiString)Caller);
18227 if(!Route2MultiMap.empty())
18229 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
18231 if(Route2MultiMapIterator->second.first > RouteNumber)
18233 Route2MultiMapIterator->second.first--;
18250 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
18251 if(!Route2MultiMap.empty())
18253 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
18255 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
18257 Route2MultiMapIterator->second.second--;
18276 AnsiString(ELink));
18280 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
18281 if(RequiredRoutePair.first == -1)
18283 throw Exception(
"Failed to find route element in RemoveRouteElement");
18285 Route2MultiMap.erase(Route2MultiMapIterator);
18286 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
18289 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
18310 GetModifiableRouteAt(8, RequiredRoutePair.first).EraseRouteElementAt(&(GetModifiableRouteAt(9, RequiredRoutePair.first).GetModifiablePrefDirElementAt(1,
18311 RequiredRoutePair.second)));
18322 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
18330 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
18332 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
18333 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
18334 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
18346 if(!LockedRouteVector.empty())
18350 if(LRVIT->RouteNumber > RequiredRoutePair.first)
18352 LRVIT->RouteNumber--;
18362 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
18364 AutoSigVectorIT->RouteNumber--;
18369 CheckMapAndRoutes(7);
18383 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
18384 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
18385 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
18401 "," + AnsiString(XLinkPos));
18405 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
18406 if(RouteElementPair.first == -1)
18408 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
18410 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
18412 RequiredPair = RouteElementPair;
18413 if(RouteElement.
XLinkPos != XLinkPos)
18415 if(SecondPair.first != -1)
18417 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
18418 RequiredPair = SecondPair;
18419 if(RouteElement.
XLinkPos != XLinkPos)
18421 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
18426 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
18430 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
18450 AnsiString(AccessNumber));
18452 int Attribute = AccessNumber + 1;
18454 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
18458 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
18462 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
18465 x).XLinkPos] !=
End)
18467 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
18470 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
18513 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
18514 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
18515 int RearwardLinkedRouteNumber;
18541 int TrainID, TrainPosition, BehindTrainPosition;
18542 bool FoundTrain =
false, BehindTrain =
false;
18543 for(
int x = RouteStartPosition; x >= 0; x--)
18545 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
18570 if(FoundTrain && (TrainPosition > 1))
18572 for(
int x = TrainPosition; x >= 0; x--)
18577 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
18597 BehindTrain =
true;
18598 BehindTrainPosition = x;
18605 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
18622 AnsiString(RouteTruncatePosition));
18623 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber, StartPosition = RouteTruncatePosition;
18624 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
18627 bool ExamineRoute =
true;
18629 while(ExamineRoute)
18631 for(
int x = StartPosition; x >= 0; x--)
18673 if(SignalCount >= 3)
18692 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
18693 ExamineRoute =
true;
18694 StartPosition = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
18729 ExamineRoute =
false;
18744 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
18747 PrefDirElement = InternalPrefDirElement;
18748 if(LockedRouteVector.empty())
18755 bool InLockedRoute =
false;
18759 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
18763 InLockedRoute =
true;
18772 int RouteNumber, VectorCount = 0;
18777 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
18778 if(RouteType == NoRoute)
18784 GetFixedRouteAt(140, RouteNumber).
PrefDirSize() - 1).XLinkPos != LRVIT->LastXLinkPos))
18787 (
"Error, last element in locked route doesn't correspond with last element in associated route in IsElementInLockedRouteGetPrefDirElement");
18789 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
18791 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
18792 if(InternalPrefDirElement.
TrackVectorPosition != (
int)LRVIT->TruncateTrackVectorPosition)
18796 PrefDirElement = InternalPrefDirElement;
18797 LockedVectorNumber = VectorCount;
18802 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->TruncateTrackVectorPosition)
18806 PrefDirElement = InternalPrefDirElement;
18807 LockedVectorNumber = VectorCount;
18828 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18830 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
18836 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
18846 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18848 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
18863 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18865 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
18868 return(GetFixedRouteAt(159, x));
18871 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
18879 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18881 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
18884 return(GetModifiableRouteAt(15, x));
18887 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
18897 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
18899 TOneRoute OneRoute = GetFixedRouteAt(165, x);
18911 int NumberOfRoutes;
18915 for(
int x = 0; x < NumberOfRoutes; x++)
18922 StoreOneRouteAfterSessionLoad(0, &OneRoute);
18940 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
18947 if((NextID < 0) || (NextID > 1000000))
18952 for(
int x = 0; x < NumberOfRoutes; x++)
18977 AnsiString(StartPosition));
18978 if(EndPosition == StartPosition)
18984 int TVPos = EndPosition;
18985 int LkPos = EndXLinkPos;
18987 while(TrackIsInARoute(15, TVPos, LkPos))
19014 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
19023 if((NewLkPos == 0) || (NewLkPos == 2))
19043 if(TVPos == StartPosition)
19075 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
19080 if(FirstPair.first > -1)
19083 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19088 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19094 if(SecondPair.first > -1)
19097 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19102 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19108 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
19115 if(FirstPair.first > -1)
19118 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19123 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19129 if(SecondPair.first > -1)
19132 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19137 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19143 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
19150 if(FirstPair.first > -1)
19153 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19158 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19164 if(SecondPair.first > -1)
19167 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19172 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19178 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
19185 if(FirstPair.first > -1)
19188 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19193 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19199 if(SecondPair.first > -1)
19202 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19207 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19213 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
19237 "," + AnsiString(DiagonalLinkNumber));
19242 if(FirstPair.first > -1)
19245 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19250 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19256 if(SecondPair.first > -1)
19259 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19264 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19271 if(FirstPair.first > -1)
19274 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19279 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19285 if(SecondPair.first > -1)
19288 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19293 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
19300 if(FirstPair.first > -1)
19303 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19308 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19314 if(SecondPair.first > -1)
19317 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19322 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
19329 if(FirstPair.first > -1)
19332 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19337 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
19343 if(SecondPair.first > -1)
19346 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
19351 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))